package com.wyd.flowable.delegate;

import lombok.extern.slf4j.Slf4j;
import org.flowable.common.engine.api.delegate.Expression;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.ExecutionListener;
import org.springframework.stereotype.Component;

import java.util.Arrays;

/**
 * 结论：任务的启动执行监听器可以设置流程变量供节点任务使用
 */
@Component
@Slf4j
public class ExecutionListener4 implements ExecutionListener {
    private Expression type1;

    @Override
    public void notify(DelegateExecution execution) {
        log.info("进入执行监听器4方法：节点key={} 节点名称={} 流程实例id={} variables={} type1={}", execution.getCurrentActivityId(), execution.getCurrentFlowElement().getName(),
                execution.getProcessInstanceId(), execution.getVariables(), type1 == null ? null : type1.getValue(execution));

        execution.setVariable("userList", Arrays.asList("4"));
//        execution.setVariable("userId1", "1,2,3");

    }
}
